import request from './axios'

export const restApi = {
  // 获取休息记录
  getRestRecords(timeRange = 'today', userId) {
    return request({
      url: '/rest/records/',
      method: 'get',
      params: { 
        range: timeRange,
        user_id: userId
      }
    })
  },

  // 创建休息记录
  createRestRecord(data) {
    return request({
      url: '/rest/records/',
      method: 'post',
      data: {
        user_id: data.user_id,
        category: data.category,
        duration: data.duration,
        actual_duration: data.actual_duration,
        flag: data.flag
      }
    })
  },

  // 更新休息记录状态
  updateRestRecord(id, data) {
    return request({
      url: `/rest/records/${id}/`,
      method: 'patch',
      data: {
        flag: data.flag,
        actual_duration: data.actual_duration
      }
    })
  },

  // 获取统计数据
  getStatistics(userId) {
    return request({
      url: '/rest/records/statistics/',
      method: 'get',
      params: { user_id: userId }
    })
  },

  // 获取今日休息总结
  getDailySummary() {
    return request({
      url: '/rest/records/daily-summary/',
      method: 'get'
    })
  }
} 